<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" lay-filter="edit-docker-api-form">

    <div class="layui-form-item">
        <label class="layui-form-label required">docker name</label>
        <div class="layui-input-block">
            <input type="text" name="dockerName" lay-verify="required" lay-reqtext="dockerName不能为空"
                   placeholder="请输入dockerName" value="" class="layui-input">
            <input type="hidden" name="id" value="">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">host_path</label>
        <div class="layui-input-block">
            <input type="text" name="hostPath" lay-verify="required" lay-reqtext="k8sApiServerUrl不能为空"
                   placeholder="docker api  path" value="" class="layui-input">
            <tip>docker api  path 例如tcp://192.168.110.130:12375</tip>
        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">api secret</label>
        <div class="layui-input-block">
            <input name="apiVersion" class="layui-input" placeholder="请输入apiVersion"></input>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">提示</label>
        <div class="layui-input-block">
            <div>
                <br>
                <div>目前只支持PEM格式的证书。</div>
                <br>
                <div> 通常格式如下，注意绿色字体部分为证书文件标识符，不可省略，证书之间不可有空行。</div>
                <br>
                <div
                        style="color: green;">-----BEGIN CERTIFICATE-----
                </div>
                证书(BASE64编码)
                <div
                        style="color: green;">-----END CERTIFICATE-----
                </div>
                <div style="color: red;">!!!中间不可有空行!!!</div>
                <div
                        style="color: green;">-----BEGIN CERTIFICATE-----
                </div>
                私钥(BASE64编码)
                <div
                        style="color: green;">-----END CERTIFICATE-----
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">client-cert.pem</label>
        <div class="layui-input-block">
            <textarea name="clientCertPem" class="layui-textarea" placeholder="请输入clientCertPem"></textarea>
            <tip>客户端证书</tip>
        </div>

    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">client-key.pem</label>
        <div class="layui-input-block">
            <textarea name="clientKeyPem" class="layui-textarea" placeholder="请输入clientKeyPem"></textarea>
            <tip>客户端秘钥</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        $.ajax({
            url: '../docker/image/getDockerApiRecord',
            type: 'POST',
            data: {
                dockerId: localStorage.editDockerId
            },
            success: function (result) {
                if (result.code === 10000) {
                   form.val('edit-docker-api-form', result.data)
                } else {
                    layer.msg(result.msg)
                }
            }
        })

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            console.debug('data', data)
            $.ajax({
                url: '../docker/image/editDockerApiRecord',
                type: 'POST',
                data: data.field,
                success: function (result) {
                    if (result.code === 10000) {
                        parent.dockerTableReload()
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    } else {
                        layer.msg(result.msg)
                    }
                }
            })
            // var index = layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // }, function () {
            //
            //     // 关闭弹出层
            //     layer.close(index);
            //
            //     var iframeIndex = parent.layer.getFrameIndex(window.name);
            //     parent.layer.close(iframeIndex);
            //
            // });

            return false;
        });

    });
</script>
</body>
</html>
